//
//  AchievementView.m
//  村医
//
//  Created by Mac on 2017/6/7.
//  Copyright © 2017年 WX. All rights reserved.
//

#import "AchievementView.h"
#import <Masonry.h>
#import "NSAttributedString+Extension.h"

@interface AchievementView()

@property(nonatomic,weak)UILabel *totalLabel;
@property(nonatomic,weak)UILabel *directMoneyLabel;
@property(nonatomic,weak)UILabel *indirectMoneyLabel;

@end

@implementation AchievementView

+(instancetype)achievementView{
    
    AchievementView *view = [[AchievementView alloc]init];
    
    return view;
}
+(instancetype)achievementViewWithFrame:(CGRect)frame{
    
    AchievementView *view = [[AchievementView alloc]initWithFrame:frame];
    
    return view;
    
}


-(void)setInCome:(YCInComeModel *)inCome{
    
    _inCome = inCome;
    
    _totalLabel.attributedText = [NSMutableAttributedString zj_attributeStringWithPrefixString:@"提出金额: " prefixFont:16 prefixColor:[UIColor blackColor] suffixString:[judgeStringWithZero(inCome.sale_total_money) stringByAppendingString:@"元"] suffixFont:16 suffixColor:[UIColor colorWithCommonType:CommonColorBlue]];

    _directMoneyLabel.text = [judgeStringWithZero(inCome.on_sale_num) stringByAppendingString:@"张"];
    
    _indirectMoneyLabel.text = [judgeStringWithZero(inCome.tow_sale_num) stringByAppendingString:@"张"];
    
    
    
}
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self configSubViews];
    }
    return self;
}

-(void)configSubViews {
    
    
    UILabel *totalLabel = [[UILabel alloc]init];
    
    [self addSubview:totalLabel];
    
    UIView *leftView = [[UIView alloc]init];
    
    leftView.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:leftView];
    
    UIView *rightView = [[UIView alloc]init];
    
    rightView.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:rightView];
    
    UILabel *directLabel = [[UILabel alloc]init];
    
    directLabel.textAlignment = NSTextAlignmentCenter;
    
    [self addSubview:directLabel];
    
    UILabel *indirectLabel = [[UILabel alloc]init];
    
    indirectLabel.textAlignment = NSTextAlignmentCenter;
    
    [self addSubview:indirectLabel];
    
    UILabel *directMoneyLabel = [[UILabel alloc]init];
    
    directMoneyLabel.textAlignment = NSTextAlignmentCenter;
    
    [self addSubview:directMoneyLabel];
    
    UILabel *indirectMoneyLabel = [[UILabel alloc]init];
    
    indirectMoneyLabel.textAlignment = NSTextAlignmentCenter;
    
    UIView *middleView = [[UIView alloc]init];
    
    middleView.backgroundColor = [UIColor colorWithCommonType:CommonColorSeparate];
    
    UIView *bottomView = [[UIView alloc]init];
    
    bottomView.backgroundColor = [UIColor colorWithCommonType:CommonColorSubFCGray];
    
    [self addSubview:bottomView];
    
    [leftView addSubview:middleView];
    
    [self addSubview:indirectMoneyLabel];
    
    [leftView addSubview:directLabel];
    
    [leftView addSubview:directMoneyLabel];
    
    [rightView addSubview:indirectLabel];
    
    [rightView addSubview:indirectMoneyLabel];
    
    [totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(20);
        make.top.mas_equalTo(self).offset(5);
    }];
    
    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.top.equalTo(totalLabel.mas_bottom).offset(10);
        make.height.mas_equalTo(50);
    }];
    
    [middleView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.width.mas_equalTo(1);
        make.height.mas_equalTo(50);
        make.right.mas_equalTo(leftView);
        make.top.mas_equalTo(leftView);
        
    }];
    
    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self);
        make.top.equalTo(totalLabel.mas_bottom).offset(10);
        make.width.equalTo(leftView);
        make.left.mas_equalTo(leftView.mas_right);
         make.height.mas_equalTo(50);
    }];
    
    [directLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(leftView);
        make.top.mas_equalTo(leftView).offset(0);
        make.height.mas_equalTo(20);
        
    }];
    [directMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(leftView);
        make.top.mas_equalTo(directLabel.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
        
    }];
    
    [indirectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(rightView);
        make.top.mas_equalTo(rightView).offset(0);
        make.height.mas_equalTo(20);
        
    }];
    [indirectMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(rightView);
        make.top.mas_equalTo(directLabel.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
        
    }];
    
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(self);
        make.height.mas_equalTo(6);
    }];
    self.totalLabel = totalLabel;
    self.directMoneyLabel = directMoneyLabel;
    self.indirectMoneyLabel = indirectMoneyLabel;
  
    totalLabel.attributedText = [NSMutableAttributedString zj_attributeStringWithPrefixString:@"提出金额:" prefixFont:16 prefixColor:[UIColor blackColor] suffixString:@" 0.0元" suffixFont:16 suffixColor:[UIColor colorWithCommonType:CommonColorBlue]];
    
    directMoneyLabel.text = @"0张";
    
    directLabel.text = @"直接销售";
    
    indirectMoneyLabel.text = @"0张";
    
    indirectLabel.text = @"间接销售";
    
}



@end


